package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class  ReturOperation implements IOperation{

    @Override
    public void work(BookList books) {
        System.out.println("归还图书！");
        System.out.println("请输入想要归还的图书");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.next();
        for (int i=0;i<books.getUserSize();i++) {
            Book book= books.getBooks(i);//将返回的引用给book
            if(book.getName().equals(name))//用book去调用Book类的getName
            {
                if(book.isBorrowde()) {
                    book.setBorrowde(false);
                    System.out.println("归还成功");
                }
                return;
            }
        }
        System.out.println("没有找到该书！");
    }
}
